package sy.controller;

import org.hibernate.mapping.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import sy.pageModel.DataGrid;
import sy.pageModel.Json;
import sy.pageModel.Secondary;
import sy.service.SecondaryServiceI;
import sy.util.StringUtil;

/**
 * Created by Administrator on 2016-07-13.
 */
@Controller
@RequestMapping("secondaryController")
public class SecondaryController {

    @Autowired
    private SecondaryServiceI secondaryService;

    @RequestMapping("/datagrid.action")
    @ResponseBody
    public DataGrid findSecondaryAction(Secondary currency){
        return secondaryService.findSecondaryDataGird(currency);
    }
    @RequestMapping("/add_currency.action")
    @ResponseBody
    public Json addPicAction(Secondary curr){
        int rows=0;
        try {
            rows=secondaryService.addServiceAction(curr);
        } catch (Exception e) {
            e.printStackTrace();
            rows=0;
        }
        Json js= StringUtil.findJson(rows,"添加");
        return js;
    }
    @RequestMapping("/edit_currency.action")
    @ResponseBody
    public Json editPicAction(Secondary curr){
        int rows=0;
        try {
            rows=secondaryService.editServiceAction(curr);
        } catch (Exception e) {
            e.printStackTrace();
            rows=0;
        }
        Json js= StringUtil.findJson(rows,"修改");
        return js;
    }


    @RequestMapping("/remove_currency.action")
    @ResponseBody
    public Json removePicAction(Secondary curr){
        int rows=0;
        try {
            rows=secondaryService.deleteServiceAction(curr);
        } catch (Exception e) {
            e.printStackTrace();
            rows=0;
        }
        Json js= StringUtil.findJson(rows,"删除");
        return js;
    }
}
